package cn.djb.day2;

/**
 * Definition for singly-linked list.
 * public class ListNode {
 * int val;
 * ListNode next;
 * ListNode(int x) { val = x; }
 * }
 */
class Solution2 {

    public ListNode reverseList(ListNode head) {

        ListNode cur = head,pre = null;
        while (null != cur) {
            ListNode tmp = cur.next;
            cur.next = pre;
            pre = cur;
            cur = tmp;

        }

        return pre;
    }

    public static void main(String[] args) {
        Solution2 solution2 = new Solution2();

    }

}